package emu.decvices.cartridge.mappers;

import java.io.Serializable;

/**
 * 卡带头信息
 */
public class RomHeader implements Serializable {
    /**
     * ROM头信息长度 为16字节
     */
    public static final int HEADER_LEN = 16;
    /**
     * PRG_ROM每块的大小，16KB
     */
    public static final int PRG_ROM_CHUCK_LEN = 1024*16;//16KB
    /**
     * CHR_ROM每块的大小，8KB
     */
    public static final int CHR_ROM_CHUCK_LEN = 1024*8;//8KB
    /**
     * trainer区域大小 512字节
     */
    public static final int TRAINER_LEN = 512;//512 bytes

    private char[] name;// 4E 45 53 1A    恒定，每个ROM前四个字节，对应”NES[sub]“   [sub]:Substitute( 替补 / 替换 )
    /*
        程序块个数，每个程序块16kb
     */
    private int prgRomChunks;
    /*
        图像块个数，每个图像块8kb
     */
    private int chrRomChunks;

    private int mapper;

    private boolean trainer;//是否存在废弃块部分(ROM中没有使用的预留部分)

    //其余部分后期补充
    private boolean sramEnable;//是否支持电池保存

    public RomHeader(char[] name, int prgRomChunks, int chrRomChunks, int mapper, boolean trainer,boolean sramEnable) {
        this.name = name;
        this.prgRomChunks = prgRomChunks;
        this.chrRomChunks = chrRomChunks;
        this.mapper = mapper;
        this.trainer = trainer;
        this.sramEnable = sramEnable;
    }

    public char[] getName() {
        return name;
    }

    public int getPrgRomChunks() {
        return prgRomChunks;
    }

    public int getChrRomChunks() {
        return chrRomChunks;
    }

    public int getMapper() {
        return mapper;
    }

    public boolean isTrainer() {
        return trainer;
    }

    public boolean isSramEnable() {
        return sramEnable;
    }
}
